package de.tabuma.wsdl2xform.xform.controller;

import de.tabuma.wsdl2xform.xform.logik.ProjectFacade;
import de.tabuma.lib.tabumacontroller;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import de.tabuma.wsdl2xform.logik.*;
import de.tabuma.wsdl2xform.xform.*;
import de.tabuma.wsdl2xform.xform.entity.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.google.appengine.api.users.*;

/**
 *
 * @author $Author: alefen $
 * @version $Revision: 1.3.4.1 $
 * @since $Date: 2010/01/13 10:23:56 $
 */
public class projectOverview extends tabumacontroller {

    private static Logger log = Logger.getLogger(projectOverview.class.getName());

    public projectOverview(String servlet, Hashtable paramter) {
        super(servlet, paramter);
    }

    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out)  {
        try {
            UserService userService = UserServiceFactory.getUserService();
            User user = userService.getCurrentUser();

            request.setAttribute(de.tabuma.wsdl2xform.controller.constants.XFORM_PROJECT_LIST, ProjectFacade.getProjectList(user.getEmail()));

            log.fine("Navigate");

            if(request.getParameter(de.tabuma.wsdl2xform.controller.constants.XFORM_PROJECT_DROPED_MODE)!=null) {
                request.setAttribute(de.tabuma.wsdl2xform.controller.constants.XFORM_PROJECT_DROPED_MODE,"true");
                List<Project> projectList = ProjectFacade.getDropedProjectList(user.getEmail());
                request.setAttribute(constants.PROJECT_LIST, projectList);
                log.fine("DROPED MODE");

            }
            else {
                List<Project> projectList = ProjectFacade.getActivProjectList(user.getEmail());
                request.setAttribute(constants.PROJECT_LIST, projectList);
                log.fine("NORMAL MODE");
            }
        }
        catch(Exception e) {
            log.warning(e.getMessage());
        }

    }

}
